package com.leyou.item.mapper;

import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author 岩冰
 * @version 1.0
 * @date:2018/9/25
 */
public interface BrandMapper extends Mapper<Brand> , SelectByIdListMapper<Brand,Long> {
    @Insert("insert into tb_category_brand values(#{cid},#{bid})")
    void insertCategoryBrand(@Param("cid") Long cid, @Param("bid")Long bid);

    @Select("select b.* from tb_brand b LEFT join tb_category_brand cb on b.id=cb.brand_id where category_id=#{cid} ")
    List<Brand> selectBrandsByCategoryId(@Param("cid") Long cid);
}
